/**************************************************************************************************/
/* Copyright (C) Lin WenGuang, 2023
/*                                                                                                */
/*  FILE NAME             :  main.go                                                               */
/*  PRINCIPAL AUTHOR      :  Lin WenGuang                                                             */
/*  SUBSYSTEM NAME        :  menu                                                                 */
/*  MODULE NAME           :  menu                                                                 */
/*  LANGUAGE              :  GO                                                                    */
/*  TARGET ENVIRONMENT    :  ANY                                                                  */
/*  DATE OF FIRST RELEASE :  2023/03/24                                                           */
/*  DESCRIPTION           :  This is a menu program                                                */
/**************************************************************************************************/

/*
 * Revision log:
 *
 * Version2.0 released by Lin WenGuang, 2023/03/24
 *
 * Version1.0 created by Lin Wenguang, 2023/03/18
 *
 */

package main

import (
	"fmt"
)

func createList() *DataNode {
	var nodeHead = DataNode{"help", "Show the available commands and descriptions", help, nil}
	var node1 = DataNode{"hello", "Display the greeting and version inforation", hello, nil}
	var node2 = DataNode{"quit", "Exit the program", quit, nil}
	nodeHead.next = &node1
	node1.next = &node2

	return &nodeHead
}

/*
var cmdArray = *[]DataNode{
	&DataNode{"help", "Show the available commands and descriptions", help, &DataNode[1]},
	&DataNode{"hello", "Display the greeting and version inforation", hello, &DataNode[2]},
	&DataNode{"quit", "Exit the program", quit, nil},
}
*/

func main() {
	fmt.Println("Welcome to MenuCLI, you can type 'help' to get more information.")
	for {
		var cmd string
		var headList = createList()
		fmt.Println("\nPlease input the command:")
		fmt.Scanln(&cmd)
		searchCmd(headList, cmd)
		/*
			if cmd == "help" {
				fmt.Println("The menu list:")
				fmt.Println("1. help -- display the menu list")
				fmt.Println("2. hello -- greeting")
				fmt.Println("3. quit -- quit the program")
			} else if cmd == "hello" {
				fmt.Println("Hello, this is MenuCLI")
			} else if cmd == "quit" {
				break
			} else {
				fmt.Println("Command is not found, please input 'help' to get the menu list")
			}
		*/
	} //for
}
